﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApp3
{
    /// <summary>
    /// TreeView.xaml 的交互逻辑
    /// </summary>
    public partial class TreeView : Window
    {
        public TreeView()
        {
            InitializeComponent();
            //ShowTreeView();
        }
        //private void ShowTreeView() {
        //    DirectoryInfo directoryInfo = new DirectoryInfo(@"E:\Everything");
        //    List<Node> nodes = new List<Node>();
        //    nodes.Add(GetChildren(directoryInfo));
        //    //绑定节点
        //    tv.ItemsSource = nodes;
          
        //}
        ////private void ShowTreeView2() {
        ////    DirectoryInfo directoryInfo = new DirectoryInfo(@"E:\Everything");
        ////    List<Node> nodes = new List<Node>();
        ////    //处理Html
        ////    for (int i = 0; i < directoryInfo.GetFiles().Length; i++)
        ////    {
        ////        nodes.Add(new Node { Name =directoryInfo.GetFiles()[i].Name.Replace(".html","") });
        ////    }
        ////    for (int i = 0; i < directoryInfo.GetFiles().Length; i++)
        ////    {
        ////        nodes.Add()
        ////    }
        ////    }
        ////}
        //public Node GetChildren(DirectoryInfo directoryInfo) {
        //    Node node = new Node() { Name = directoryInfo.Name };
        //    var subDirectory = directoryInfo.GetDirectories();
        //    var files=directoryInfo.GetFiles();
        //    if (files.Length!=0)
        //    {
        //        foreach (var item in files)
        //        {
        //            //获取文件名称
        //            node.Children.Add(new Node {Name=item.Name.Replace(".txt","") });
        //        }
        //    }
        //    if (subDirectory.Length!=0)
        //    {
        //        foreach (var item in subDirectory)
        //        {
        //            node.Children.Add(GetChildren(item));
        //        }
        //    }
        //    return node;
        //}

        //private void tv_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        //{
        //    TreeView treeView = (TreeView)sender;
            
        //}

        //private void Button_Click(object sender, RoutedEventArgs e)
        //{
        //    if (string.IsNullOrEmpty(textBox1.Text.Trim()))
        //    {
        //        return ;
        //    }
            
        //}
        //private void SearchLayer(Node node, string name) {
          
        //}
    }
}
